<?php
namespace x;
class Config
{
    public static $con;
    public static function setConfig(){
        $con = [];
        //其他配置
        $dir = APP_PATH.'config';
        if (false != ($handle = opendir ( $dir ))) {
            while ( false !== ($file = readdir ( $handle )) ) {
                if ($file != "." && $file != ".." && strpos($file,".")) {
                    $key = strtolower(str_replace(".php",'',$file));
                    $con[$key] = include APP_PATH.'config/'.$file;
                }
            }
            closedir ( $handle );
        }
        self::$con = $con;
    }

    //获取值,支持取到二维
    public static function get($key=''){
        $arr = explode('.',$key);
        $con = self::$con;
        $rs = $con;
        if( isset($arr[0]) && isset($con[$arr[0]]) )
            $rs = $con[$arr[0]];
        if( isset($arr[1]) && isset($con[$arr[0]][$arr[1]]) )
            $rs = $con[$arr[0]][$arr[1]];
        return $rs;
    }
}
